package com.cz.ssyx.client.product;

import com.cz.ssyx.model.product.Category;
import com.cz.ssyx.model.product.SkuInfo;
import com.cz.ssyx.vo.product.SkuInfoVo;
import com.cz.ssyx.vo.product.SkuStockLockVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@FeignClient(value = "service-product")
public interface ProductFeignClient {

    @GetMapping("/api/product/inner/getCategory/{categoryId}")
    Category getCategoryById(@PathVariable("categoryId") Long categoryId);

    @GetMapping("/api/product/inner/getSkuInfo/{skuInfoId}")
    SkuInfo getSkuInfoById(@PathVariable("skuInfoId") Long skuInfoId);

    @PostMapping("/api/product/inner/findSkuInfoList")
    List<SkuInfo> findSkuInfoList(@RequestBody List<Long> skuIdList);

    @GetMapping("/api/product/inner/findSkuInfoByKeyword/{keyword}")
    List<SkuInfo> findSkuInfoByKeyword(@PathVariable String keyword);

    @PostMapping("/api/product/inner/findCategoryList")
    List<Category> findCategoryList(@RequestBody List<Long> categoryIdList);

    @GetMapping("/api/product/inner/findAllCategoryList")
    List<Category> findAllCategoryList();

    //获取所有新人专享商品
    @GetMapping("/api/product/inner/findNewPersonSkuInfoList")
    List<SkuInfo> findNewPersonSkuInfoList();

    @GetMapping("/api/product/inner/getSkuInfoVo/{skuId}")
    SkuInfoVo getSkuInfoVoById(@PathVariable Long skuId);

    //验证并锁定库存
    @PostMapping("/api/product/inner/checkAndLock/{orderNo}")
    Boolean checkAndLock(@RequestBody List<SkuStockLockVo> skuStockLockVo,
                                @PathVariable String orderNo);

    //因超时未付款释放库存
    @PostMapping("/api/product/inner/timeOutUnLockStock")
    void timeOutUnLockStock(@RequestBody HashMap<Long, Integer> TimeoutOrderMap);
}
